-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(auth): dispatch signInWithRedirect error #12653
Conversation
cbe8a37
to
ddb74cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change makes sense to me! Pending some more unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lgtm
const error = new AuthError({ | ||
message: errorMessage ?? 'An error has occurred during the oauth proccess', | ||
name: AuthErrorCodes.OAuthSignInError, | ||
recoverySuggestion: authErrorMessages.oauthSignInError.log, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be overwriting the recoverySuggestion
of the inner error - https://github.com/aws-amplify/amplify-js/pull/12653/files#diff-fdb5c0bae1596a54b5b5443374724d08f48f716455ce40743ad6e377a45cfcaeR397
5f7cb9b
to
4c57fdd
Compare
3152ce4
to
055ffcf
Compare
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
packages/auth/__tests__/providers/cognito/signInWithRedirect.test.ts
Outdated
Show resolved
Hide resolved
c0cec3e
to
653bc26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you! @israx
@@ -116,6 +116,8 @@ export async function oauthSignIn({ | |||
const { type, error, url } = | |||
(await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ?? | |||
{}; | |||
// This code will run in RN applications only as calling signInWithRedirect will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think it's more relevant here to say that openAuthSession
will resolve in RN
// This code will run in RN applications only as calling signInWithRedirect will | ||
// resolve the promise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here
store.loadOAuthState().then(resp => { | ||
savedState = resp; | ||
}); | ||
async function validateState(state?: string | null): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since this is now actually returning something, I would opt for a name that better reflects the new behavior. E.g. getValidatedState
Description of changes
In case of an oauth exception:
Issue #, if available
Description of how you validated changes
created a sample app in web and validated that the library dispatches a
signInWithRedirect_failure
under the following circumstances:responseType
iscode
and there is an error returned from hostedUIresponseType
iscode
and the oauth state is not validresponseType
istoken
and there is an error returned from hostedUIresponseType
istoken
and the oauth state is not validPR was validated in RN with the same testing criteria as above.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.